<?= isset($header) ? $header : '' ?>

<div id="content">
    <div class="form_style">

        <div class="title">			
            <div class="title" style="font-size: 20px;padding: 10px 1px 0px 18px;">
                <a href="#" class="client" >客戶資料編輯</a>｜
                <a href="#" class="contact" >聯絡人</a>｜
                <a href="#" class="relationship" >關係人</a>			
            </div>
        </div>

        <div id="client_info">	
            <form method="post" id="userinfo" action="<?= site_url('/client/data_edit_submit') ?>" >
                <!--
                表单从这里开始
                -->
                <table>
                    <tr>
                    	
                        <th style="width:65px;" id="w1" class="must_write">客戶姓名</th>
                        <td>
                            <input type="hidden" id="client_id" name="client_id" value="<?= $client->client_id ?>">
                            <?php
                            
                            $login_data = $this -> session -> all_userdata();		
							//if($login_data["is_see"]<=$client->is_see){
							//	 mask_data($client->name);
								
                        	                            
							//}else{
							?>
								<input type="text" id="name" name="name" value="<?= $client->name ?>">
							<?php	
							//}
                            ?>

                        </td>
                        <th style="width:65px;" id="w2">特徴</th>
                        <td>
                            <input type="text" id="recommended" name="recommended" value="<?= $client->recommended ?>">
                        </td>
                        <th style="width:65px;" id="w3">重要性</th>
                        <td>
                            <select class="full_select" id="importance" name="importance">
                                <option value="">&nbsp;</option>
                                <?
                                foreach($importance_of_customers as $key=>$val){
                                ?>
                                <option value="<?= $val->value ?>" <?
                                        if ($client -> importance == $val -> value)
                                        echo "selected";
                                        ?>><?= $val->value ?></option>
                                <?
                                }
                                ?>
                            </select>
                        </td>
                        <th style="width:65px;" id="w4">國籍</th>
                        <td>
                            <select id="nationality" name="nationality"  class="full_select">
                                <?
                                foreach($nationality as $key=>$val){
                                ?>
                                <option value="<?= $val->nationality_id ?>" <?
                                        if ($client -> nationality == $val -> nationality_id)
                                        echo "selected";
                                        ?>><?= $val->value ?></option>
                                <?
                                }
                                ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>英文姓名</th>
                        <td><input type="text" id="english_name" name="english_name" value="<?= $client->english_name ?>"></td>
                        <th>性別</th>
                        <td>
                            <input type="radio" value="1" id="sex" name="sex" <?
                                   if ($client -> sex == "1")
                                   echo "checked";
                                   ?>>男&nbsp;&nbsp;<input type="radio" value="0" id="sex" name="sex" <?
                                   if ($client -> sex == "0")
                                   echo "checked";
                                   ?>>女
                        </td>
                        <th>客戶來源</th>
                        <td>
                            <select class="full_select" id="customer_source" name="customer_source">
                                <option value="">&nbsp;</option>
                                <?
                                foreach($customer_source as $key=>$val){
                                ?>
                                <option value="<?= $val->customer_source_id ?>" <?
                                        if ($client -> customer_source == $val -> customer_source_id)
                                        echo "selected";
                                        ?>><?= $val->value ?></option>
                                <?
                                }
                                ?>
                            </select>
                        </td>

                        <th>備註其他</th>
                        <td><input type="button" onclick="detail_info();" value="詳細訊息" class="input_background"></td>
                    </tr>

                    <tr>
                        <th>行動電話</th>
                        <td colspan="3">
                            <ul id="add_tel">
                            	<?
                            		//if($login_data["is_see"]<=$client->is_see){
									 	//mask_number($client->mobile);								                        
								//	}else{
	                                ?>
	                                	<li id="mobile_1">
	                                			<input type="text" class="mobile" style="width:260px;" id="mobile1" name="mobile1" value="<?= $client->mobile1 ?>"> 
	                                			<a class="deleteitem" onclick="remove_mobile(1)">
	                                				<i class="icon-trash">&nbsp;&nbsp;</i>
	                                			</a>
	                                	</li>
	                                
                                <li name="mobile_li">
                                    <input type="text" class="mobile" style="width:260px;" id="mobile" name="mobile" value="<?= $client->mobile ?>" > <a onclick="add_mobile()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                </li>
                                <?
								//	}
                            	?>
                                <?php
                            
                                if($client->mobile1!="" && $client->mobile1!="0"){
                                									
								
									//if($login_data["is_see"]<=$client->is_see){
									 //	mask_number($client->mobile1);								                        
									//}else{
	                                ?>
	                                	<li id="mobile_1">
	                                			<input type="text" class="mobile" style="width:260px;" id="mobile1" name="mobile1" value="<?= $client->mobile1 ?>"> 
	                                			<a class="deleteitem" onclick="remove_mobile(1)">
	                                				<i class="icon-trash">&nbsp;&nbsp;</i>
	                                			</a>
	                                	</li>
	                                <?
									//}
								
								
                                }
                                if($client->mobile2!="" && $client->mobile2!="0"){
                                	
                                //if($login_data["is_see"]<=$client->is_see){
									 	//mask_number($client->mobile2);								                        
								//	}else{
	                                ?>
	                                	<li id="mobile_1">
	                                			<input type="text" class="mobile" style="width:260px;" id="mobile2" name="mobile2" value="<?= $client->mobile2 ?>"> 
	                                			<a class="deleteitem" onclick="remove_mobile(2)">
	                                				<i class="icon-trash">&nbsp;&nbsp;</i>
	                                			</a>
	                                	</li>
	                                <?
								//	}
                                
                                }
                                ?>
                            </ul>
                        </td>
                        <th>簡訊發送</th>
                        <td colspan="5">
                            <ul id="mobilesms">
                                <li><input type="radio"  value="Y" id="send_sms" name="send_sms" <?
                                           if ($client -> send_sms == "Y")
                                           echo "checked";
                                           ?> >Y&nbsp;<input type="radio" value="N" id="send_sms" name="send_sms" <?
                                           if ($client -> send_sms == "N")
                                           echo "checked";
                                           ?> >N</li>
                                <?
                                if($client->mobile1!="" && $client->mobile1!="0"){
                                ?>
                                <li id="mobile_1"><input type="radio" value="Y" id="send_sms1" name="send_sms1" <?
                                                         if ($client -> send_sms1 == "Y")
                                                         echo "checked";
                                                         ?>>Y&nbsp;<input type="radio" value="N" id="send_sms1" name="send_sms1" <?
                                                         if ($client -> send_sms1 == "N")
                                                         echo "checked";
                                                         ?>>N</li>
                                <?
                                }
                                if($client->mobile2!="" && $client->mobile2!="0"){
                                ?>
                                <li id="mobile_2"><input type="radio"  value="Y" id="send_sms2" name="send_sms2" <?
                                                         if ($client -> send_sms2 == "Y")
                                                         echo "checked";
                                                         ?>>Y&nbsp;<input type="radio" value="N" id="send_sms2" name="send_sms2" <?
                                                         if ($client -> send_sms2 == "N")
                                                         echo "checked";
                                                         ?>>N</li>
                                <?
                                }
                                ?>
                            </ul>
                        </td>
                    </tr>
                    <tr>
                        <th>住家電話</th>
                        <td colspan="7">
                            <ul id="home_tel">
                            	
                            	<?php
                            
                            $login_data = $this -> session -> all_userdata();		
							//if($login_data["is_see"]<=$client->is_see){
							//	 mask_number($client->home_phone);								               
							//}else{
							?>
							
                                <li>
                                    <input type="text" class="colspan_input1" style="width:260px;" id="home_phone" name="home_phone" value="<?= $client->home_phone ?>"> <a onclick="add_home_phone()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                </li>
                                
                                <?php	
							//}
                            
							
                                if($client->home_phone1!="" && $client->home_phone1!="0"){
                                	
								 		
									//if($login_data["is_see"]<=$client->is_see){
									//	 mask_number($client->home_phone1);								               
									//}else{	
                                	?>
                                		<li id="home_phone_1"><input type="text" id="home_phone1" name="home_phone1" class="colspan_input1"  style="width:260px;" value="<?= $client->home_phone1 ?>"><a class="deleteitem" onclick="remove_home_phone(1)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
                                	<?
                                	//}
									
								}


                                if($client->home_phone2!="" && $client->home_phone2!="0"){
                                	
									
                                	
								 		
									//if($login_data["is_see"]<=$client->is_see){
										 //mask_number($client->home_phone2);								               
									//}else{	
		                                ?>
		                                <li id="home_phone_2"><input type="text" id="home_phone2" name="home_phone2" class="colspan_input1" style="width:260px;" value="<?= $client->home_phone2 ?>"><a class="deleteitem" onclick="remove_home_phone(2)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
		                                <?
									//}
									
									
                                }
                                ?>
                            </ul>
                        </td>

                    </tr>
                    <tr>
                        <th>公司電話</th>
                        <td colspan="7">
                            <ul id="company_tel">
                                <li>
                                    <input type="text" class="colspan_input1" style="width:260px;" id="company_phone" name="company_phone" value="<?= $client->company_phone ?>">&nbsp;&nbsp;<b>分機</b>&nbsp;&nbsp;<input type="text" class="c_tel_2" value="<?= $client->company_phone_ext ?>" id="company_phone_ext" name="company_phone_ext"><a onclick="add_company_phone()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>		    			
                                </li>
                                <?
                                if($client->company_phone1!="" && $client->company_phone1!="0"){
                                ?>
                                <li id="company_phone_1"><input type="text" class="colspan_input1" style="width:260px;" id="company_phone1" name="company_phone1" value="<?= $client->company_phone1 ?>">&nbsp;&nbsp;<b>分機</b>&nbsp;&nbsp;<input type="text" id="company_phone_ext1" name="company_phone_ext1" class="c_tel_2" value="<?= $client->company_phone_ext1 ?>" ><a class="deleteitem" onclick="remove_company_phone(1)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
                                <?
                                }
                                if($client->company_phone2!="" && $client->company_phone2!="0"){
                                ?>
                                <li id="company_phone_2"><input type="text" class="colspan_input1" style="width:260px;" id="company_phone2" name="company_phone2" value="<?= $client->company_phone2 ?>">&nbsp;&nbsp;<b>分機</b>&nbsp;&nbsp;<input type="text" id="company_phone_ext2" name="company_phone_ext2" class="c_tel_2" value="<?= $client->company_phone_ext2 ?>"><a class="deleteitem" onclick="remove_company_phone(2)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
                                <?
                                }
                                ?>
                            </ul>	
                        </td>
                    </tr>
                    <tr>
                        <th>電子郵件</th>
                        <td colspan="3">
                            <ul id="email0">
                            	
                            	<?php
                            	//if($login_data["is_see"]<=$client->is_see){
							//			 mask_data($client->email);								               
							//	}else{	                            	
                            	?>
                                <li>
                                    <input type="text" id="email" name="email" class="email_input" value="<?= $client->email ?>" onblur="checkemail('email')">
                                    <input type="button" onclick="open_email('email');" value="開啟mail" class="input_background">
                                    <a onclick="add_email();" class="additem">
                                        <i class="icon-plus">&nbsp;&nbsp;</i></a>	
                                </li>
                                
                                <?php //} ?>
                                
                                <?
                                if($client->email1!="" && $client->email1!="0"){
                                ?>
                                
		                                <?php
		                            	//if($login_data["is_see"]<=$client->is_see){
									//			 mask_data($client->email1);								               
									//	}else{	                            	
		                            	?>
		                            	
			                                <li id="email_1">
			                                    <input type="text" class="email_input" id="email1" name="email1" value="<?= $client->email1 ?>" onblur="checkemail('email')">
			                                    <input type="button" onclick="open_email('email1')" value="開啟mail" class="input_background">
			
			                                    <a class="deleteitem" onclick="remove_email(1)">
			                                        <i class="icon-trash">
			                                            &nbsp;&nbsp;
			                                        </i>
			                                    </a>
			                                </li>
			                                
		                                <?
										//}
										?>
								
								
								<?php
								
								
								
								
                                }
                                if($client->email2!="" && $client->email2!="0"){
                                	
									//if($login_data["is_see"]<=$client->is_see){
									//			 mask_data($client->email2);								               
									//	}else{	
			                                ?>
			                                <li id="email_2"><input type="text" class="email_input" id="email2" name="email2" value="<?= $client->email2 ?>" onblur="checkemail('email')"><input type="button" onclick="open_email('email2')" value="開啟mail" class="input_background"><a class="deleteitem" onclick="remove_email(2)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
			                                <?
									//	}
                                }
                                ?>
                            </ul>
                        </td>
                        <th>寄發EDM</th>
                        <td colspan="5">
                            <ul id="email_edm">
                                <li>
                                    <input type="radio" <?
                                           if ($client -> send_email == "Y")
                                           echo "checked";
                                           ?> value="Y" id="send_email" name="send_email">Y&nbsp;&nbsp;<input type="radio" value="N" id="send_email" name="send_email" <?
                                           if ($client -> send_email == "N")
                                           echo "checked";
                                           ?>>N
                                </li>
                                <?
                                if($client->email1!="" && $client->email1!="0"){
                                ?>
                                <li class="7" id="send_email_1"><input type="radio"  value="Y" id="send_email1" name="send_email1" <?
                                                                       if ($client -> send_email1 == "Y")
                                                                       echo "checked";
                                                                       ?>>Y&nbsp;&nbsp;<input type="radio" value="N" id="send_email1" name="send_email1" <?
                                                                       if ($client -> send_email1 == "N")
                                                                       echo "checked";
                                                                       ?>>N</li>
                                <?
                                }
                                if($client->email2!="" && $client->email2!="0"){
                                ?>
                                <li class="7" id="send_email_2"><input type="radio" value="Y" id="send_email2" name="send_email2" <?
                                                                       if ($client -> send_email2 == "Y")
                                                                       echo "checked";
                                                                       ?> >Y&nbsp;&nbsp;<input type="radio" value="N" id="send_email2" name="send_email2" <?
                                                                       if ($client -> send_email2 == "N")
                                                                       echo "checked";
                                                                       ?>>N</li>
                                <?
                                }
                                ?>
                            </ul>
                        </td>
                    </tr>
                    <tr>
                        <th>傳真電話</th>
                        <td colspan="7">
                            <ul id="fax_u">
                                <li>
                                    <input type="text" class="colspan_input1" style="width:260px;" id="fax" name="fax" value="<?= $client->fax ?>" > <a onclick="add_fax();" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                </li>
                                <?
                                if($client->fax1!="" && $client->fax1!="0"){
                                ?>
                                <li id="fax_1"><input type="text" class="colspan_input1" style="width:260px;" id="fax1" name="fax1" value="<?= $client->fax1 ?>"><a class="deleteitem" onclick="remove_fax(1)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
                                <?
                                }
                                if($client->fax2!="" && $client->fax2!="0"){
                                ?>
                                <li id="fax_2"><input type="text" class="colspan_input1" style="width:260px;" id="fax2" name="fax2" value="<?= $client->fax2 ?>"><a class="deleteitem" onclick="remove_fax(2)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
                                <?
                                }
                                ?>
                            </ul>
                        </td>
                    </tr>
                    <tr>
                        <th>住家地址</th>
                        <td colspan="3">
                            <ul id="home_addr">
                            	
                            	<?php
	                            		//if($login_data["is_see"]<=$client->is_see){
									//				 mask_data($client->home_address);								               
									//	}else{	
		                            	?>
		                                <li>
		                                    <input type="text" onclick="show_address('home_address');" class="colspan_input" id="home_address" name="home_address" value="<?= $client->home_address ?>">
		                                    <a onclick="add_home_address();" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
		                                </li>
		                                <?php
									//	}
                                ?>
                                
                                <?
                                if($client->home_address1!="" && $client->home_address1!="0"){
                                	
                                	//if($login_data["is_see"]<=$client->is_see){
								//					 mask_data($client->home_address1);								               
								//		}else{
			                                ?>
			                                <li id="home_address_1"><input type="text" id="home_address1" name="home_address1" class="colspan_input" onclick="show_address('home_address1');" value="<?= $client->home_address1 ?>"><a class="deleteitem" onclick="remove_home_address(1)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
			                                <?
								//		}
                                }
                                if($client->home_address2!="" && $client->home_address2!="0"){
                                	
									//if($login_data["is_see"]<=$client->is_see){
									//				 mask_data($client->home_address2);								               
									//	}else{
			                                ?>
			                                <li id="home_address_2"><input type="text" id="home_address2" name="home_address2" class="colspan_input" onclick="show_address('home_address2');" value="<?= $client->home_address2 ?>"><a class="deleteitem" onclick="remove_home_address(2)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
			                                <?
                                		//}
								}
                                ?>
                            </ul>
                        </td>
                        <?php
                        $bu_name = array();
                        foreach ($building_name as $key => $val) {
                            $bu_name[$val->building_name_id] = $val->value;
                        }
                        ?>
                        <th>住家-大樓名稱</th>
                        <td>
                            <?php
                            $home_building_name = '';
                            foreach ($bu_name as $key => $value) {
                                if ($client->home_building_name == $key) {
                                    $home_building_name = $value;
                                }
                            }
                            ?>
                            <ul id="building_name">
                                <li>
                                    <input id="home_building_name" name="home_building_name" size="50" style="width:148px;" value="<?= $client->home_building_name ?>" />
                                </li>
                                <?php
                                if (!empty($client->home_building_name1)) {
                                    ?>
                                    <li id="home_building_name_1">
                                        <input id="home_building_name1" name="home_building_name1" size="50" style="width:148px;" value="<?= $client->home_building_name1 ?>" />
                                    </li>
                                    <?
                                    }
                                    if(!empty($client->home_building_name2)) {
                                    ?>
                                    <li id="home_building_name_2">
                                        <input id="home_building_name2" name="home_building_name2" size="50" style="width:148px;" value="<?= $client->home_building_name2 ?>" /></li>
                                    <?
                                    }
                                    ?>
                                </ul>
                            </td>
                            <th>寄發刊物</th>
                            <td colspan="3">
                                <ul id="per">
                                    <li>
                                        <input type="radio" <?
                                               if ($client -> home_send_publication == "Y")
                                               echo "checked";
                                               ?> value="Y" id="home_send_publication" name="home_send_publication" >Y&nbsp;&nbsp;<input type="radio" <?
                                               if ($client -> home_send_publication == "N")
                                               echo "checked";
                                               ?> value="N" id="home_send_publication" name="home_send_publication">N
                                    </li>
                                    <?
                                    if($client->home_building_name1!="" && $client->home_building_name1!="0"){
                                    ?>
                                    <li id="home_send_publication_1">
                                        <input type="radio" <?
                                               if ($client -> home_send_publication1 == "Y")
                                               echo "checked";
                                               ?> value="Y" id="home_send_publication1" name="home_send_publication1">Y&nbsp;&nbsp;<input type="radio" value="N" <?
                                               if ($client -> home_send_publication1 == "N")
                                               echo "checked";
                                               ?> id="home_send_publication1" name="home_send_publication1">N
                                    </li>
                                    <?
                                    }
                                    if($client->home_building_name2!="" && $client->home_building_name2!="0"){
                                    ?>
                                    <li id="home_send_publication_2">
                                        <input type="radio" <?
                                               if ($client -> home_send_publication2 == "Y")
                                               echo "checked";
                                               ?>  value="Y" id="home_send_publication2" name="home_send_publication2">Y&nbsp;&nbsp;<input type="radio" value="N" <?
                                               if ($client -> home_send_publication2 == "N")
                                               echo "checked";
                                               ?> id="home_send_publication2" name="home_send_publication2">N
                                    </li>
                                    <?
                                    }
                                    ?>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>公司名稱</th>
                            <td colspan="3">
                                <ul id="company_name0">
                                    <li>
                                        <input type="text" class="colspan_input" id="company_name" name="company_name" value="<?= $client->company_name ?>" > 
                                        <a onclick="add_company();" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                        <div id="showco"></div>
                                    </li>
                                    <?
                                    if($client->company_name1!="" && $client->company_name1!="0"){
                                    ?>
                                    <li id="company_name_1"><input type="text" name="company_name1" id="company_name1" class="colspan_input" value="<?= $client->company_name1 ?>" ><a class="deleteitem" onclick="remove_company(1)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
                                    <?
                                    }
                                    if($client->company_name2!="" && $client->company_name2!="0"){
                                    ?>
                                    <li id="company_name_2"><input type="text" name="company_name2" id="company_name2" class="colspan_input" value="<?= $client->company_name2 ?>" ><a class="deleteitem" onclick="remove_company(2)"><i class="icon-trash">&nbsp;&nbsp;</i></a></li>
                                    <?
                                    }
                                    ?>
                                </ul>
                            </td>
                            <th>公司類型</th>
                            <td>
                                <ul id="company_type">
                                    <li>
                                        <select class="full_select" id="type_of_company" name="type_of_company">
                                            <?
                                            foreach($type_of_company as $key=>$val){
                                            ?>
                                            <option value="<?= $val->type_of_company_id ?>" <?
                                                    if ($client -> type_of_company == $val -> type_of_company_id)
                                                    echo "selected";
                                                    ?> ><?= $val->value ?></option>
                                            <?
                                            }
                                            ?>
                                        </select>
                                    </li>
                                    <?
                                    if($client->company_name1!="" && $client->company_name1!="0"){
                                    ?>
                                    <li class="13" id="type_of_company_1">
                                        <select class="full_select" id="type_of_company1" name="type_of_company1">
                                            <?
                                            foreach($type_of_company as $key=>$val){
                                            ?>
                                            <option value="<?= $val->type_of_company_id ?>" <?
                                                    if ($client -> type_of_company1 == $val -> type_of_company_id)
                                                    echo "selected";
                                                    ?> ><?= $val->value ?></option>
                                            <?
                                            }
                                            ?>
                                        </select></li>
                                    <?
                                    }
                                    if($client->company_name2!="" && $client->company_name2!="0"){
                                    ?>
                                    <li class="13" id="type_of_company_2">
                                        <select class="full_select" id="type_of_company2" name="type_of_company2">
                                            <?
                                            foreach($type_of_company as $key=>$val){
                                            ?>
                                            <option value="<?= $val->type_of_company_id ?>" <?
                                                    if ($client -> type_of_company2 == $val -> type_of_company_id)
                                                    echo "selected";
                                                    ?> ><?= $val->value ?></option>
                                            <?
                                            }
                                            ?>
                                        </select></li>
                                    <?
                                    }
                                    ?>
                                </ul>
                            </td>
                            <th>統一編號</th>
                            <td colspan="3">
                                <ul id="company_id">
                                    <li>
                                        <input type="text" style="width:148px;" onblur="checkunicode();" name="unicode" id="unicode" value="<?= $client->unicode ?>" ><span class="error" id="uniformcode"></span>
                                    </li>
                                    <?
                                    if($client->company_name1!="" && $client->company_name1!="0"){
                                    ?>
                                    <li class="13" id="unicode_1"><input type="text" style="width:148px;" id="unicode1" name="unicode1" value="<?= $client->unicode1 ?>"></li>
                                    <?
                                    }
                                    if($client->company_name2!="" && $client->company_name2!="0"){
                                    ?>
                                    <li class="13" id="unicode_2"><input type="text" style="width:148px;" id="unicode2" name="unicode2" value="<?= $client->unicode2 ?>"></li>
                                    <?
                                    }
                                    ?>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>部門</th>
                            <td>
                                <ul id="dept">
                                    <li> 
                                        <input type="text" id="department" name="department" value="<?= $client->department ?>"> </li>
                                    <?
                                    if($client->company_name1!="" && $client->company_name1!="0"){
                                    ?>
                                    <li class="13" id="department_1"><input type="text" name="department1" id="department1" value="<?= $client->department1 ?>"></li>
                                    <?
                                    }
                                    if($client->company_name2!="" && $client->company_name2!="0"){
                                    ?>
                                    <li class="13" id="department_2"><input type="text" name="department2" id="department2" value="<?= $client->department2 ?>"></li>
                                    <?
                                    }
                                    ?>
                                </ul>

                            </td>
                            <th>職稱</th>
                            <td colspan="3">
                                <ul id="zhichen">
                                    <li>
                                        <select  class="full_select" style="width:auto;" id="title" name="title">
                                            <option value=""> </option>
                                            <?
                                            foreach($title as $key=>$val){
                                            ?>
                                            <option value="<?= $val->title_id ?>" <?
                                                    if ($client -> title == $val -> title_id)
                                                    echo "selected";
                                                    ?>><?= $val->value ?></option>
                                            <?
                                            }
                                            ?>
                                        </select>
                                    </li>
                                    <?
                                    if($client->company_name1!="" && $client->company_name1!="0"){
                                    ?>
                                    <li class="13" id="title_1">
                                        <select  class="full_select" style="width:auto;" id="title1" name="title1">
                                            <option value=""> </option>
                                            <?
                                            foreach($title as $key=>$val){
                                            ?>
                                            <option value="<?= $val->title_id ?>" <?
                                                    if ($client -> title1 == $val -> title_id)
                                                    echo "selected";
                                                    ?>><?= $val->value ?></option>
                                            <?
                                            }
                                            ?>
                                        </select></li>
                                    <?
                                    }
                                    if($client->company_name2!="" && $client->company_name2!="0"){
                                    ?>
                                    <li class="13" id="title_2">
                                        <select  class="full_select" style="width:auto;" id="title2" name="title2">
                                            <option value=""> </option>
                                            <?
                                            foreach($title as $key=>$val){
                                            ?>
                                            <option value="<?= $val->title_id ?>" <?
                                                    if ($client -> title2 == $val -> title_id)
                                                    echo "selected";
                                                    ?>><?= $val->value ?></option>
                                            <?
                                            }
                                            ?>
                                        </select></li>
                                    <?
                                    }
                                    ?>
                                </ul>
                            </td>
                            <th>類別</th>
                            <td>
                                <ul id="company_type2">
                                    <li>
                                        <input id="category" name="category" size="50" style="width:148px;" value="<?= $client->category ?>"   />
                                    </li>
                                    <?
                                    if($client->company_name1!="" && $client->company_name1!="0"){
                                    ?>
                                    <li class="13" id="category_1">
                                        <input id="category1" name="category1" size="50" style="width:148px;" value="<?= $client->category1 ?>"   /></li>
                                    <?
                                    }
                                    if($client->company_name2!="" && $client->company_name2!="0"){
                                    ?>
                                    <li class="13" id="category_2">
                                        <input id="category2" name="category2" size="50" style="width:148px;" value="<?= $client->category2 ?>"   /></li>
                                    <?
                                    }
                                    ?>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>公司地址</th>
                            <td colspan="3">
                                <ul id="company_addr">
                                    <li><input type="text" id="company_address" class="large_input" style="width:373px;" name="company_address" value="<?= $client->company_address ?>" onclick="show_address('company_address');">
                                    </li>
                                    <?
                                    if($client->company_name1!="" && $client->company_name1!="0"){
                                    ?>
                                    <li id="company_address_1"><input type="text" name="company_address1" class="large_input" style="width:373px;" id="company_address1" value="<?= $client->company_address1 ?>"></li>
                                    <?php
                                }
                                if ($client->company_name2 != "" && $client->company_name2 != "0") {
                                    ?>
                                    <li id="company_address_2">
                                        <input type="text" name="company_address2" class="large_input" style="width:373px;" id="company_address2" value="<?= $client->company_address2 ?>">
                                    </li>
                                    <?
                                    }
                                    ?>
                                </ul>
                            </td>

                            <th>公司-大樓名稱</th>
                            <td>
                                <ul id="building_company_name">
                                    <li>
                                        <input id="company_building_name" name="company_building_name" size="50" style="width:148px;"   value="<?= $client->company_building_name ?>" />
                                    </li>
                                    <?php
                                    if ($client->company_building_name1 != "" && $client->company_building_name1 != "0") {
                                        ?>
                                        <li>
                                            <input id="company_building_name1" name="company_building_name1" size="50" style="width:148px;"  value="<?= $client->company_building_name1 ?>"  />
                                        </li>
                                        <?php
                                    }
                                    if ($client->company_building_name2 != "" && $client->company_building_name2 != "0") {
                                        ?>
                                        <li>
                                            <input id="company_building_name2" name="company_building_name2" size="50" style="width:148px;"  value="<?= $client->company_building_name2 ?>" />
                                        </li>
                                        <?php
                                    }
                                    ?>
                                </ul>
                            </td>



                            <th>寄發刊物</th>
                            <td colspan="3">
                                <ul id="per_com">
                                    <li><input type="radio" <?
                                               if ($client -> company_send_publication == "Y")
                                               echo "checked";
                                               ?> value="Y" id="company_send_publication" name="company_send_publication">Y&nbsp;&nbsp;<input type="radio" <?
                                               if ($client -> company_send_publication == "N")
                                               echo "checked";
                                               ?> value="N" id="company_send_publication" name="company_send_publication">N</li>
                                    <?
                                    if($client->company_building_name1!="" && $client->company_building_name1!="0"){
                                    ?>
                                    <li id="company_send_publication_1"><input type="radio" name="company_send_publication1" id="company_send_publication1" value="Y" <?
                                                                               if ($client -> company_send_publication1 == "Y")
                                                                               echo "checked";
                                                                               ?> >Y&nbsp;&nbsp;<input type="radio" name="company_send_publication1" id="company_send_publication1" value="N" <?
                                                                               if ($client -> company_send_publication1 == "N")
                                                                               echo "checked";
                                                                               ?>>N</li>
                                    <?
                                    }
                                    if($client->company_building_name2!="" && $client->company_building_name2!="0"){
                                    ?>
                                    <li id="company_send_publication_2"><input type="radio" name="company_send_publication2" id="company_send_publication2" value="Y" <?
                                                                               if ($client -> company_send_publication2 == "Y")
                                                                               echo "checked";
                                                                               ?>>Y&nbsp;&nbsp;<input type="radio" name="company_send_publication2" id="company_send_publication2" value="N" <?
                                                                               if ($client -> company_send_publication2 == "N")
                                                                               echo "checked";
                                                                               ?>>N</li>
                                    <?
                                    }
                                    ?>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>公司網址</th>
                            <td colspan="7">
                                <ul id="company_website0">
                                    <li>
                                        <input type="text" id="company_website" style="width:374px;" name="company_website" value="<?= $client->company_website ?>" ><input type="button" onclick="open_website('company_website');" value="開啟IE" class="input_background">
                                    </li>
                                    <?
                                    if($client->company_name1!="" && $client->company_name1!="0"){
                                    ?>
                                    <li id="company_website_1"><input type="text" name="company_website1" style="width:374px;" id="company_website1" value="<?= $client->company_website1 ?>"><input type="button" onclick="open_website('company_website1');" value="開啟IE" class="input_background"></li>

                                    <?
                                    }
                                    if($client->company_name2!="" && $client->company_name2!="0"){
                                    ?>
                                    <li id="company_website_2"><input type="text" name="company_website2" style="width:374px;" id="company_website2" value="<?= $client->company_website2 ?>"><input type="button" onclick="open_website('company_website2');" value="開啟IE" class="input_background"></li>
                                    <?
                                    }
                                    ?>

                                </ul>
                            </td>
                        </tr>
                        
                        
                         <tr>
                            <th>機密等級</th>
                            <td>
                            	
                                <select name="sercet_level" id="sercet_level"  >	
									<option value="1" <?= ($client->sercet_level==1)?"SELECTED":"" ?> >普通</option>						
									<option value="3" <?= ($client->sercet_level==3)?"SELECTED":"" ?> >極機密</option>
									<option value="2" <?= ($client->sercet_level==2)?"SELECTED":"" ?> >機密</option>														
								</select>
                            </td>

                            <th>是否公開</th>
                            <td>
                                
                                <select name="is_public" id="is_public"  >														
									<option value="1" <?= ($client->is_public==1)?"SELECTED":"" ?> >公開</option>
									<option value="2" <?= ($client->is_public==2)?"SELECTED":"" ?> >不公開</option>							
								</select>	    		
                            </td>

                            <th>重要性</th>
                            <td>
                            	<select name="important" id="important" >
									<option value="1"   <?= ($client->important==1)?"SELECTED":"" ?>  >普通</option>								
									<option value="3"   <?= ($client->important==3)?"SELECTED":"" ?> >極重要</option>
									<option value="2"   <?= ($client->important==2)?"SELECTED":"" ?> >重要</option>												
								</select>
                            </td>

                            <th style="display: none;">遮蔽欄位</th>
                            <td style="display: none;">
                               <select name="is_see" id="is_see" >														
									<option value="2" <?= ($client->is_see==2)?"SELECTED":"" ?>>遮蔽</option>
									<option value="1" <?= ($client->is_see==1)?"SELECTED":"" ?>>不遮蔽</option>							
								</select>
                            </td>
                        </tr>
                        
                        			  
                        <tr>
                            <th>接待人</th>
                            <td>
                                <?php
                                //$this->call_users_name($client -> front_man);
                                foreach ($users as $user) {
                                    if ($user->users_id == $client->front_man) {
                                        echo $user->name;
                                    }
                                }
                                ?>
                                <input type="hidden" value="<?= $client->front_man ?>" id="front_man" name="front_man"></td>
                            <th>指派主管</th>
                            <td>
                                <?php
                                foreach ($users as $user) {
                                    if ($user->users_id == $client->head) {
                                        echo $user->name;
                                    }
                                }
                                ?>

                                <input type="hidden" id="head" name="head" value="<?= $client->head ?>">
                            </td>
                            <th>原經紀人</th>
                            <td><input type="hidden" id="original_broker" name="original_broker" value="<?= $client->original_broker ?>"></td>
                            <th>經紀人</th>

                            <td>
                                <input type="hidden" id="broker" name="broker" value="<?= $client->broker ?>">
                                <?php
                                foreach ($users as $user) {
                                    if ($user->users_id == $client->broker) {
                                        echo $user->name;
                                    }
                                }
                                ?>		    		
                            </td>

                        </tr>
                    </table>


                    <!-- 表单在这里结束 -->
                    <div id="detail_info" style="display: none;">

                        

                        <table class="detail_info">

                            <tbody>

                                <tr>
                                    <th width="80" class="utitle">生日</th>
                                    <td width="110"><input type="text" class="Wdate" onclick="WdatePicker()" id="birthday" name="birthday" value="<?= $client->birthday ?>"></td>
                                    <th width="70" class="utitle">送禮</th>
                                    <td>
                                            <input type="radio" value="Y" id="gifts" name="gifts" <?
                                               if ($client -> gifts == "Y")
                                               echo "checked";
                                               ?>>Y&nbsp;&nbsp;
                                            <input type="radio" value="N" id="gifts" name="gifts" <?
                                               if ($client -> gifts == "N")
                                               echo "checked";
                                               ?>>N
                                           </td>
                                </tr>

                                <tr>
                                    <th class="utitle">身分證字號</th>
                                    <td colspan="3"><input type="text" style="width:95px;" name="id_number" id="id_number" value="<?= $client->id_number ?>" onblur="checkidnumber();">
                                        <span class="error" id="carderrorinfo"></span></td>
                                </tr>
                                <tr>
                                    <th class="utitle">平常連絡</th>
                                    <td colspan="3">
                                        <ul id="ping">
                                            <li class="ping_li">
                                                <select style="width:70px;" id="usually_contact" name="usually_contact">
                                                    <option value=""></option>
                                                    <?
                                                    foreach($contact_usual_holiday as $key=>$val){
                                                    ?>
                                                    <option value="<?= $val->contact_usual_holiday_id ?>" <?
                                                            if ($client -> usually_contact == $val -> contact_usual_holiday_id)
                                                            echo "selected";
                                                            ?>><?= $val->value ?></option>
                                                    <?
                                                    }
                                                    ?>
                                                </select>
                                                &nbsp;&nbsp;&nbsp;
                                                起&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="usually_start_time" name="usually_start_time" value="<?= $client->usually_start_time ?>">&nbsp;&nbsp;&nbsp;
                                                止&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="usually_end_time" name="usually_end_time" value="<?= $client->usually_end_time ?>">
                                                <a onclick="add_usually_contact()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                            </li>
                                            <?
                                            if($client->usually_contact1!="" && $client->usually_contact1!="0"){
                                            ?>
                                            <li class="ping_li">
                                                <select style="width:70px;" id="usually_contact1" name="usually_contact1">
                                                    <option value=""></option>
                                                    <?
                                                    foreach($contact_usual_holiday as $key=>$val){
                                                    ?>
                                                    <option value="<?= $val->contact_usual_holiday_id ?>" <?
                                                            if ($client -> usually_contact1 == $val -> contact_usual_holiday_id)
                                                            echo "selected";
                                                            ?>><?= $val->value ?></option>
                                                    <?
                                                    }
                                                    ?>
                                                </select>
                                                &nbsp;&nbsp;&nbsp;
                                                起&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="usually_start_time1" name="usually_start_time1" value="<?= $client->usually_start_time1 ?>">&nbsp;&nbsp;&nbsp;
                                                止&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="usually_end_time1" name="usually_end_time1" value="<?= $client->usually_end_time1 ?>">
                                                <a class='deleteitem' onclick='remove_usually_contact(1)'><i class='icon-trash'>&nbsp;&nbsp;</i></a>
                                            </li>
                                            <?
                                            }
                                            ?>

                                            <?
                                            if($client->usually_contact2!="" && $client->usually_contact2!="0"){
                                            ?>
                                            <li class="ping_li">
                                                <select style="width:70px;" id="usually_contact2" name="usually_contact2">
                                                    <option value=""></option>
                                                    <?
                                                    foreach($contact_usual_holiday as $key=>$val){
                                                    ?>
                                                    <option value="<?= $val->contact_usual_holiday_id ?>" <?
                                                            if ($client -> usually_contact2 == $val -> contact_usual_holiday_id)
                                                            echo "selected";
                                                            ?>><?= $val->value ?></option>
                                                    <?
                                                    }
                                                    ?>
                                                </select>
                                                &nbsp;&nbsp;&nbsp;
                                                起&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="usually_start_time2" name="usually_start_time2" value="<?= $client->usually_start_time2 ?>">&nbsp;&nbsp;&nbsp;
                                                止&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="usually_end_time2" name="usually_end_time2" value="<?= $client->usually_end_time2 ?>">
                                                <a class='deleteitem' onclick='remove_usually_contact(2)'><i class='icon-trash'>&nbsp;&nbsp;</i></a>
                                            </li>
                                            <?
                                            }
                                            ?>
                                        </ul>				    	
                                    </td>
                                </tr>
                                <tr>
                                    <th class="utitle">假日連絡</th>
                                    <td colspan="3">
                                        <ul id="holiday">
                                            <li class="holiday_li">
                                                <select id="holidays_contact" style="width:70px;" name="holidays_contact">
                                                    <option value=""></option>
                                                    <?
                                                    foreach($contact_usual_holiday as $key=>$val){
                                                    ?>
                                                    <option value="<?= $val->contact_usual_holiday_id ?>" <?
                                                            if ($client -> holidays_contact == $val -> contact_usual_holiday_id)
                                                            echo "selected";
                                                            ?>><?= $val->value ?></option>
                                                    <?
                                                    }
                                                    ?>
                                                </select>&nbsp;&nbsp;&nbsp;&nbsp;
                                                起&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="holidays_start_time" name="holidays_start_time" value="<?= $client->holidays_start_time ?>">&nbsp;&nbsp;&nbsp;
                                                止&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="holidays_end_time" name="holidays_end_time" value="<?= $client->holidays_end_time ?>">
                                                <a onclick="add_holidays_contact()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                            </li>

                                            <?
                                            if($client->holidays_contact1!="" && $client->holidays_contact1!="0"){
                                            ?>
                                            <li class="holiday_li" id="holidays_contact_1">
                                                <select id="holidays_contact1" style="width:70px;" name="holidays_contact1">
                                                    <option value=""></option>
                                                    <?
                                                    foreach($contact_usual_holiday as $key=>$val){
                                                    ?>
                                                    <option value="<?= $val->contact_usual_holiday_id ?>" <?
                                                            if ($client -> holidays_contact1 == $val -> contact_usual_holiday_id)
                                                            echo "selected";
                                                            ?>><?= $val->value ?></option>
                                                    <?
                                                    }
                                                    ?>
                                                </select>&nbsp;&nbsp;&nbsp;&nbsp;
                                                起&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="holidays_start_time" name="holidays_start_time1" value="<?= $client->holidays_start_time1 ?>">&nbsp;&nbsp;&nbsp;
                                                止&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="holidays_end_time" name="holidays_end_time1" value="<?= $client->holidays_end_time1 ?>">
                                                <a class='deleteitem' onclick='remove_holidays_contact(1)'><i class='icon-trash'>&nbsp;&nbsp;</i></a>
                                            </li>
                                            <?
                                            }
                                            ?>

                                            <?
                                            if($client->holidays_contact2!="" && $client->holidays_contact2!="0"){
                                            ?>
                                            <li class="holiday_li" id="holidays_contact_2">
                                                <select id="holidays_contact2" style="width:70px;" name="holidays_contact2">
                                                    <option value=""></option>
                                                    <?
                                                    foreach($contact_usual_holiday as $key=>$val){
                                                    ?>
                                                    <option value="<?= $val->contact_usual_holiday_id ?>" <?
                                                            if ($client -> holidays_contact2 == $val -> contact_usual_holiday_id)
                                                            echo "selected";
                                                            ?>><?= $val->value ?></option>
                                                    <?
                                                    }
                                                    ?>
                                                </select>&nbsp;&nbsp;&nbsp;&nbsp;
                                                起&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="holidays_start_time2" name="holidays_start_time2" value="<?= $client->holidays_start_time2 ?>">&nbsp;&nbsp;&nbsp;
                                                止&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="holidays_end_time2" name="holidays_end_time2" value="<?= $client->holidays_end_time2 ?>">
                                                <a class='deleteitem' onclick='remove_holidays_contact(2)'><i class='icon-trash'>&nbsp;&nbsp;</i></a>
                                            </li>
                                            <?
                                            }
                                            ?>
                                        </ul>
                                    </td>			    
                                </tr>
                                <tr>
                                    <th class="utitle">背景與特色</th>
                                    <td class="cu_charac" colspan="3"><textarea id="background_and_features" name="background_and_features" class="utextarea"><?= $client->background_and_features ?></textarea></td>
                                </tr>
                                <tr>
                                    <td align="center" colspan="4">
                                        <input type="button" onclick="detail_info_determine();" value="確定" class="input_background">
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    
                    </div>

                    <?php
                    $this->load->view("showbox/address");
                    ?>



                </form>
            </div>

            <div id="contact_info" style="display: none;">
                <div id="client_info">
                    <input type="button" class="btn" value="增加聯絡人" OnClick="add_contact();">
                    <?php
                    $i = 0;
                    ?>

                    <form  id="contact_info" >


                        <?php
                        foreach ($contacts as $contact) {
                            ?>

                            <input type="hidden" name="ref_client_verify_code" value="<?= $contact->ref_client_verify_code; ?>">
                            <table id="contact_count" style="margin: 10px;">

                                <tr id="w1">
                                    <th style="width:65px;" id="w3" class="must_write">客戶姓名</th>
                                    <td>
                                        <input type="text" style="width:138px;"  name="contact[<?= $i ?>][name]" value="<?= $contact->name ?>">
                                        <input type="hidden" name="contact[<?= $i ?>][contact_id]" value="<?= $contact->client_contact_id; ?>">
                                    </td>

                                    <th style="width:65px;" id="w3">英文姓名</th>
                                    <td>
                                        <input type="text" id="recommended" name="contact[<?= $i ?>][english_name]" value="<?= $contact->english_name ?>">
                                    </td>

                                    <th style="width:65px;" id="sex" id="w3">性別</th>
                                    <td colspan="3">
                                        男
                                        <input type="radio" name="contact[<?= $i ?>][sex]" <?php
                                        if ($contact->sex == "1")
                                            echo "checked";
                                        ?> value="1">
                                        女	
                                        <input type="radio" name="contact[<?= $i ?>][sex]" <?php
                                        if ($contact->sex == "0")
                                            echo "checked";
                                        ?> value="0">
                                    </td>
                                </tr>


                                <tr id="w2">
                                    <th style="width:65px;" id="w2">行動電話</th>
                                    <td>
                                        <input type="text" name="contact[<?= $i ?>][mobile]" value="<?= $contact->mobile ?>">
                                    </td>

                                    <th style="width:65px;" id="w2">住家電話</th>
                                    <td>
                                        <input type="text" name="contact[<?= $i ?>][home_phone]" value="<?= $contact->home_phone ?>">
                                    </td>

                                    <th style="width:65px;" id="w2">公司電話</th>
                                    <td>
                                        <input type="text" name="contact[<?= $i ?>][company_phone]" value="<?= $contact->company_phone ?>" >
                                    </td>

                                    <th style="width:65px;" id="w2">傳真</th>
                                    <td>
                                        <input type="text" name="contact[<?= $i ?>][fax]" value="<?= $contact->fax ?>">
                                    </td>
                                </tr>    

                                <tr id="w1">                            
                                    <th style="width:65px;" id="w3">住家地址</th>
                                    <td colspan="3">
                                        <input type="text" style="width:300px;" name="contact[<?= $i ?>][home_address]" value="<?= $contact->home_address ?>" id="contact_home_address_<?= $i ?>" onClick="show_address('contact_home_address_<?= $i ?>')" >
                                    </td>

                                    <th style="width:65px;" id="w3">公司地址</th>
                                    <td colspan="3">
                                        <input type="text" style="width:300px;" name="contact[<?= $i ?>][company_address]" value="<?= $contact->company_address ?>" id="contact_company_address_<?= $i ?>" onClick="show_address('contact_company_address_<?= $i ?>')" >
                                    </td>
                                </tr>    

                            </table>
                            <?php
                            $i++;
                        }
                        ?>


                        <div id="html_contact">                	
                        </div>







                    </form>	
                </div>
            </div>	



            <style>
                .btn {
                    background-color: #ccc;
                    -moz-border-radius: 5px;
                    -webkit-border-radius: 5px;
                    border-radius: 6px;
                    color: #000;
                    font-family: 'Oswald';
                    font-size: 20px;
                    text-decoration: none;
                    cursor: pointer;
                    border: none;
                }

                #relationship_info table th {
                    background: #e9e9e9;
                    color: #666666;
                    padding: 4px 8px;
                    text-align: left;
                    white-space: nowrap;
                    height: 32px;
                    line-height: 32px;
                    padding: 10px;
                }

                #relationship_info table tr {
                    background: none repeat scroll 0 0 transparent;
                    border: 0 none;
                    font-size: 100%;
                    margin: 0;
                    outline: 0 none;
                    padding: 0;
                    vertical-align: baseline;
                }

                #contact_info table th {
                    background: #e9e9e9;
                    color: #666666;
                    padding: 4px 8px;
                    text-align: left;
                    white-space: nowrap;
                    height: 32px;
                    line-height: 32px;
                    padding: 10px;
                }

                #contact_info table tr {
                    background: none repeat scroll 0 0 transparent;
                    border: 0 none;
                    font-size: 100%;
                    margin: 0;
                    outline: 0 none;
                    padding: 0;
                    vertical-align: baseline;
                }
            </style>

            <div id="relationship_info" style="display: none;">


                <input type="button" class="btn" value="增加關係人" OnClick="add_relationship();">



                <?php $i = 0; ?>
                <form  id="relationship_info_form" >


                    <?php

                    foreach ($relationships as $relation) {                        

                    ?>
                        <input type="hidden" name="ref_client_verify_code" value="<?= $relation->ref_client_verify_code; ?>">
                        <input type="hidden" name="relation[<?=$i?>][client_relationship_id]" value="<?= $relation->client_relationship_id; ?>">
                        <table id="contact_count" style="margin: 10px;">

                            <tr id="w1">
                                <th style="width:65px;" id="w3" class="must_write">客戶姓名</th>
                                <td>
                                    <input type="text"   name="relation[<?= $i ?>][name]" value="<?= $relation->name ?>">

                                </td>

                                <th style="width:65px;" id="w3">英文姓名</th>
                                <td>
                                    <input type="text" id="recommended" name="relation[<?= $i ?>][english_name]" value="<?= $relation->english_name ?>" >
                                </td>

                                <th style="width:65px;" id="sex" id="w3">性別</th>

                                <td colspan="3">

                                    男
                                    <input type="radio" name="relation[<?= $i ?>][sex]" <?php
                                    if ($relation->sex == "1")
                                        echo "checked";
                                    ?> value="1" >
                                    
                                    女	
                                    <input type="radio" name="relation[<?= $i ?>][sex]" <?php
                                    if ($relation->sex == "0")
                                        echo "checked";
                                    ?> value="0" >
                                </td>

                            </tr>


                            <tr id="w2">
                                <th style="width:65px;" id="w2">行動電話</th>
                                <td>
                                    <input type="text" name="relation[<?= $i ?>][mobile]" value="<?= $relation->mobile ?>" >
                                </td>

                                <th style="width:65px;" id="w2">住家電話</th>
                                <td>
                                    <input type="text" name="relation[<?= $i ?>][home_phone]" value="<?= $relation->home_phone ?>">
                                </td>

                                <th style="width:65px;" id="w2">公司電話</th>
                                <td>
                                    <input type="text" name="relation[<?= $i ?>][company_phone]" value="<?= $relation->company_phone ?>">
                                </td>

                                <th style="width:65px;" id="w2">傳真</th>
                                <td>
                                    <input type="text" name="relation[<?= $i ?>][fax]" value="<?= $relation->fax ?>" >
                                </td>
                            </tr>    

                            <tr id="w1">                            
                                <th style="width:65px;" id="w3">住家地址</th>
                                <td colspan="3">
                                    <input type="text" style="width:300px;" name="relation[<?= $i ?>][home_address]"  value="<?= $relation->home_address ?>" id="relation_home_address_<?= $i ?>" onClick="show_address('relation_home_address_<?= $i ?>')" >
                                </td>

                                <th style="width:65px;" id="w3">公司地址</th>
                                <td colspan="3">
                                    <input type="text" style="width:300px;" name="relation[<?= $i ?>][company_address]" value="<?= $relation->company_address ?>"  id="relation_company_address_<?= $i ?>" onClick="show_address('relation_company_address_<?= $i ?>')" >
                                </td>
                            </tr>    

                        </table>

                        <?php
                        $i++;
                    }
                    ?>


                    <div id="html_relationship">                	
                    </div>





                </form>


            </div>
        </div>

        
        	
    </div>
    
    <table style="margin:0px 0px 0px 957px;">
            <tr>

                <td colspan="5"></td>              
                <td>
                    <?php
                    if ($send_to_admin) {
                        ?>
                        <input type="button" onclick="update_checkform_send_to_admin()"  value="主管審核" class="input_background" id="send_to_admin">
                        <?php
                    }
                    ?>
                </td>
                <td class="last_save">              	
                    <input type="hidden" id="client_id" name="client_id" value="<?= $client->client_id ?>">
                    <input type="button" id="update_checkform" onclick="update_checkform()" value="存檔" class="input_background">				  
                </td>               
                <td  class="last_save">
                
                </td>

            </tr>			
        </table>



    <div style="margin:10px;"></div>
    <?= isset($footer) ? $footer : '' ?>